<template>
  <div class="supervise-list-outer-wrapper"
       :class="{
      'print-supervise': !showPagination
    }">
    <div class="supervise-list-container">
      <StatisticTabsHeader v-show="isShowStatisticalToolBar"
                           class="statistic-tabs-header"
                           v-model="currentChooseVal"
                           :tabsList="statisticListArr"
                           v-if="statisticListArr.length"
                           @handleChange="dataTypeChange"></StatisticTabsHeader>
      <div class="pending-list-main"
           v-if="currentChooseVal !== 'workflowBug'"
           :style="{
          top:
            (statisticListArr.length && isShowStatisticalToolBar) || !showPagination ? '44px' : '0'
        }">
        <SpecialSearchCondition v-if="isShowSpecialSearchCondition"
                                :listData="specialSearchConditionList"
                                :selectedValue="specialSearchSelectedValue"
                                @itemClicked="onSpecialSearchConditionClicked"></SpecialSearchCondition>
        <div :id="searchConditionContainerId"></div>
        <div class="pending-list-header">
          <CommonCounter class="common-counter"
                         v-if="selectedRowKeys.length"
                         :total="pagination.total"
                         :currentSelected="selectedRowKeys.length"
                         @cancelSelected="cancelSelected" />
          <div style="flex: 1; overflow: hidden"
               class="common-toolbar">
            <CommonToolbar :allToolBtns="allToolBtns"
                           @buttonClick="buttonClick"></CommonToolbar>
          </div>
          <div class="search-part">
            <a-input-search class="search-input"
                            :placeholder="$i18n('collaboration.new.template.search.keyWords')"
                            style="width: 272px"
                            :allowClear="true"
                            @search="handleSearch"
                            @buttonClick="buttonClick" />
            <div style="margin-left: 12px; display: flex">
              <SearchCondition class="search-condition"
                               :conditions="searchConditions"
                               :containerParentId="searchConditionContainerId"
                               @valueChange="handleSearchConditionChange"
                               @expandChange="expandChange"></SearchCondition>
            </div>
          </div>
        </div>
        <div class="pending-list-content"
             style="flex: 1"
             ref="tableContent">
          <div>
            <AVirtuallyTable ref="avirtuallyTable"
                             :row-selection="{
                columnWidth: 60,
                selectedRowKeys: selectedRowKeys,
                onChange: onSelectChange
              }"
                             rowKey="id"
                             :pagination="showPagination"
                             :loading="loading"
                             :paginationOption="pagination"
                             size="small"
                             :columns="columns"
                             :openVirtuallyModel="false"
                             :dataSource="dataSource"
                             :localstorageKey="getLocalStorageKey"
                             @paginationChange="handleTableChange"
                             @paginationShowSizeChange="paginationShowSizeChange"
                             @updadeStatisticsBar="updadeStatisticsBar">
              <!-- 标题 -->
              <span slot="subject"
                    slot-scope="{ record }">
                <SubjectTableRender :slotData="record"
                                    :dataType="dataType"></SubjectTableRender>
              </span>
              <!-- 当前待办人 -->
              <span slot="currentNodesInfo"
                    slot-scope="{ text, record }">
                <span @click="showFlowChart(record)"
                      class="currentNodesInfo"
                      :title="text">
                  {{ text }}</span>
              </span>
              <!-- 处理期限 -->
              <span slot="processDeadlineDatetimeName"
                    slot-scope="{ record }">
                <ProcessDeadLineNameTableRender :slotData="record"></ProcessDeadLineNameTableRender>
              </span>
              <!-- 流程期限 -->
              <span slot="deadlineDatetimeName"
                    slot-scope="{ record }">
                <FlowDeadLineNameTableRender :slotData="record"></FlowDeadLineNameTableRender>
              </span>
              <!-- 流程日志 -->
              <span slot="processLog"
                    slot-scope="{ record }">
                <ProcessIdTableRender :dataType="0"
                                      :slotData="record"></ProcessIdTableRender>
              </span>
            </AVirtuallyTable>
          </div>
        </div>
      </div>
      <workflow-bug :dataType="currentChooseVal"
                    :statisRecieveData="statisRecieveData"
                    :needStatisticsVal="needStatisticsVal"
                    @updadeStatisticsBar="updadeStatisticsBar"
                    v-else></workflow-bug>
    </div>
  </div>
</template>

<script>
  import CommonToolbar from '../../components/common-toolbar/index';
  import CommonCounter from '../../components/common-counter/index';
  import SearchCondition from '@/components/search-condition/index.vue';
  import StatisticTabsHeader from '@/components/statistic-tabs-header/index.vue';
  import AVirtuallyTable from '@/ant-virtually-table/table.vue';
  import SubjectTableRender from './components/subject-table-render.vue';
  import ProcessIdTableRender from './components/processId-table-render.vue';
  import ProcessDeadLineNameTableRender from './components/processDeadLineName-table-render.vue';
  import SpecialSearchCondition from '../supervise-mine/components/special-search-condition.vue';

  import FlowDeadLineNameTableRender from './components/flowDeadLineName-table-render.vue';
  import WorkflowBug from '../supervise-mine/src/workflow-bug.vue';
  import { getUrlSearchParams } from '../../utils';
  import superviseMixin from '@/mixins/supervise/supervise-mixin.js';
  import { getParams, loadComponentsThemeDefaultCSS } from '@/utils';
  import { formatRequestDataToJSON, loadExtendResource } from '@/utils/api';
  import * as Fiber from 'fiber';

  export default {
    name: 'superviseDept',
    mixins: [superviseMixin],
    components: {
      CommonToolbar,
      CommonCounter,
      SearchCondition,
      AVirtuallyTable,
      StatisticTabsHeader,
      ProcessIdTableRender,
      ProcessDeadLineNameTableRender,
      FlowDeadLineNameTableRender,
      SubjectTableRender,
      WorkflowBug,
      SpecialSearchCondition
    },
    data() {
      return {
        showPagination: true,
        affairId: 0,
        urlParamObj: {},
        currentChooseVal: '',
        managerType: 'deptAdmin',
        statisticListArr: [],
        isShowStatisticalToolBar: true, // 是否显示顶部的统计控件
        isShowTotal: true, // 是否显示统计控件的总数
        searchConditionContainerId: 'search-condition-container-parent',
        selectedRowKeys: [],
        selectedRows: [],
        pagination: {
          page: 1,
          // pageSize: 20,
          total: 100
          // pageSizeOptions: ['10', '20', '30', '40', '50'],
          // showTotal: (total) => `${this.$i18n('orgrole.total_items', total)}`,
          // showSizeChanger: true
        },
        showCounter: false,
        allToolBtns: [],
        dataSource: [],
        searchConditions: [],
        columns: [],
        searchValue: '',
        globalParam: {},
        pageHeadItems: [],
        queryCondition: {},
        loading: false,
        needStatisticsVal: false,
        statisRecieveData: null,
        memberIdStr: ''
      };
    },
    computed: {
      getLocalStorageKey() {
        return window._currentUser.id + 'SUPERVISE_DEPT';
      }
    },
    created() {
      this.urlParamObj = getUrlSearchParams();
      this.urlParamObj1 = getParams(window.location.search);
      this.memberIdStr = this.urlParamObj1.memberId
        ? decodeURIComponent(this.urlParamObj1.memberId)
        : '';
      this.initPageStatisticData();
      this.loading = true;
      this.initToolbar();
      loadComponentsThemeDefaultCSS(window._ctxPath + window._ctpSkinUrl);
    },
    methods: {
      updadeStatisticsBar(data) {
        if (data) {
          const recieveData = data;
          this.globalParam = recieveData.globalParam || {};
          this.isShowStatisticalToolBar =
            this.globalParam.isShowStatisticalToolBar === '1' ? true : false;
          this.isShowTotal = this.globalParam.isShowTotal == '1' ? true : false;
          const statisticListShowMap = {
            all: this.globalParam.haveAll,
            done: this.globalParam.haveDone,
            overdue: this.globalParam.haveOverdue,
            pending: this.globalParam.havePending,
            workflowBug: this.globalParam.haveProcessException,
            sevenDayOverdue: this.globalParam.haveNoOverdue
          };
          const hideValueKeys = ['all'];
          this.statisticListArr = recieveData.pageHead.items.filter((item) => {
            if (!this.isShowTotal) {
              item.hideValue = true;
            } else {
              if (hideValueKeys.includes(item.key)) {
                // 这几种类型不需要显示统计value
                item.hideValue = true;
              } else {
                item.hideValue = false;
              }
            }
            return statisticListShowMap[item.key];
          });
        } else {
          this.initPageStatisticData();
          this.initTableData();
        }
      },
      initToolbar() {
        this.$set(this, 'allToolBtns', []);
        //全部
        if (this.currentChooseVal == 'all') {
          this.allToolBtns.push({
            id: 'urgeDeal',
            name: this.$i18n('common.portal.section.affair.remind.label')
          });
          this.allToolBtns.push({
            id: 'export',
            name: this.$i18n('common.export.label')
          });
          this.allToolBtns.push({
            id: 'print',
            name: this.$i18n('common.toolbar.print.label')
          });
        } else if (this.currentChooseVal == 'pending') {
          //未办结
          this.allToolBtns.push({
            id: 'editWorkFlow',
            name: this.$i18n('common.design.workflow.label')
          });
          this.allToolBtns.push({
            id: 'batchEditWorkFlow',
            name: this.$i18n('collaboration.common.workflow.supervise.batch.modify'),
            tip: [
              this.$i18n('workflow.manager.supervise.modify.mag4.js'),
              '1.' + this.$i18n('workflow.manager.supervise.modify.mag5.js'),
              '2.' + this.$i18n('workflow.manager.supervise.modify.mag6.js'),
              '3.' + this.$i18n('workflow.manager.supervise.modify.mag7.js')
            ],
            subMenu: [
              {
                id: 'batchEditWorkFlow_sub',
                name: this.$i18n('collaboration.common.workflow.supervise.batch.modify')
              },
              {
                id: 'allEditWorkFlow',
                name: this.$i18n('collaboration.common.workflow.supervise.batch.modify.all')
              }
            ]
          });
          this.allToolBtns.push({
            id: 'editWorkFlowLog',
            name: this.$i18n('collaboration.common.workflow.supervise.batch.modify.log')
          });
          this.allToolBtns.push({
            id: 'urgeDeal',
            name: this.$i18n('common.portal.section.affair.remind.label')
          });
          this.allToolBtns.push({
            id: 'export',
            name: this.$i18n('common.export.label')
          });
          this.allToolBtns.push({
            id: 'print',
            name: this.$i18n('common.toolbar.print.label')
          });
        } else if (this.currentChooseVal == 'done') {
          //已办结
          this.allToolBtns.push({
            id: 'editWorkFlowLog',
            name: this.$i18n('collaboration.common.workflow.supervise.batch.modify.log')
          });
          this.allToolBtns.push({
            id: 'urgeDeal',
            name: this.$i18n('common.portal.section.affair.remind.label')
          });
          this.allToolBtns.push({
            id: 'export',
            name: this.$i18n('common.export.label')
          });
          this.allToolBtns.push({
            id: 'print',
            name: this.$i18n('common.toolbar.print.label')
          });
          this.allToolBtns.push({
            id: 'deleteSupervise',
            name: this.$i18n('common.toolbar.delete.label')
          });
        } else if (this.currentChooseVal == 'overdue' || this.currentChooseVal == 'sevenDayOverdue') {
          //已超期、七天内超期
          this.allToolBtns.push({
            id: 'urgeDeal',
            name: this.$i18n('common.portal.section.affair.remind.label')
          });
          this.allToolBtns.push({
            id: 'print',
            name: this.$i18n('common.toolbar.print.label')
          });
        } else if (this.currentChooseVal == 'workflowBug') {
          // 流程异常(未处理)
          this.allToolBtns.push({
            id: 'editWorkFlow',
            name: this.$i18n('common.design.workflow.label')
          });
          this.allToolBtns.push({
            id: 'processEnd',
            name: this.$i18n('supervise.process.End')
          });
          this.allToolBtns.push({
            id: 'processRevoke',
            name: this.$i18n('common.toolbar.repeal.label')
          });
          this.allToolBtns.push({
            id: 'dealProblem',
            name: this.$i18n('workflow.bug.set.already.deal.js')
          });
          this.allToolBtns.push({
            id: 'export',
            name: this.$i18n('common.export.label')
          });
          this.allToolBtns.push({
            id: 'print',
            name: this.$i18n('common.toolbar.print.label')
          });
        } else {
          this.allToolBtns.push({
            id: 'urgeDeal',
            name: this.$i18n('common.portal.section.affair.remind.label')
          });
          this.allToolBtns.push({
            id: 'export',
            name: this.$i18n('common.export.label')
          });
          this.allToolBtns.push({
            id: 'print',
            name: this.$i18n('common.toolbar.print.label')
          });
        }
      },
      //元数据
      initPageStatisticData() {
        const headerParams = {
          key: 'SUPERVISE',
          platform: 0,
          arguments: {
            memberId: this.memberIdStr,
            managerType: 'deptAdmin',
            superviseBoxType: this.currentChooseVal,
            boardId: this.urlParamObj1?.boardId || '',
            needStatisticsVal: this.needStatisticsVal,
            ...(this.urlParamObj1.templeteIds && { templateIds: this.urlParamObj1.templeteIds })
          }
        };
        const url = `${window._ctxPath}/rest/global/metadata/list`;
        window.axios.post(url, headerParams).then((data, err) => {
          console.log(data, err);
          const recieveData = data.data.data;
          loadExtendResource(recieveData.extra?.extendResources);
          this.statisRecieveData = recieveData;
          this.globalParam = recieveData.globalParam || {};
          this.isShowStatisticalToolBar =
            this.globalParam.isShowStatisticalToolBar === '1' ? true : false;
          this.isShowTotal = this.globalParam.isShowTotal == '1' ? true : false;
          const statisticListShowMap = {
            all: this.globalParam.haveAll,
            done: this.globalParam.haveDone,
            overdue: this.globalParam.haveOverdue,
            pending: this.globalParam.havePending,
            workflowBug: this.globalParam.haveProcessException,
            sevenDayOverdue: this.globalParam.haveNoOverdue
          };
          this.showType = this.globalParam.showType;
          const hideValueKeys = ['all'];
          this.statisticListArr = recieveData.pageHead.items.filter((item) => {
            if (!this.isShowTotal) {
              item.hideValue = true;
            } else {
              if (hideValueKeys.includes(item.key)) {
                // 这几种类型不需要显示统计value
                item.hideValue = true;
              } else {
                item.hideValue = false;
              }
            }
            return statisticListShowMap[item.key];
          });
          this.searchConditions = recieveData.searchConditions.filter(
            (item) => item.key !== 'subject'
          );
          this.columns = [];
          recieveData.tableColumns.forEach((item) => {
            if (item.type != 'CHECKBOX') {
              this.columns.push({
                title: item.title,
                width: item.width,
                dataIndex: item.key,
                ellipsis: true,
                key: item.key,
                fixed: false,
                dropdownMenus: {
                  asc: true,
                  desc: true,
                  freeze: true,
                  fieldset: true
                },
                scopedSlots: { customRender: item.key },
                customCell: () => {
                  return {
                    style: {
                      cursor: 'pointer'
                    }
                  };
                }
              });
            }
          });
          var defaultValue = '';
          for (var item in statisticListShowMap) {
            if (statisticListShowMap[item]) {
              defaultValue = item;
              break;
            }
          }
          console.log(123, defaultValue);
          const sendParams = [
            {
              managerType: 'deptAdmin',
              operationType: 'template',
              dataType: this.currentChooseVal || defaultValue,
              currentNodesInfo: this.memberIdStr,
              flowstate: '0',
              status: '0',
              haveOverdue: this.globalParam.haveOverdue,
              haveNoOverdue: this.globalParam.haveNoOverdue,
              haveProcessException: this.globalParam.haveProcessException,
              operationTypeIds: this.urlParamObj1.templeteIds || this.globalParam.templateIds || ''
            }
          ];
          const args = `managerMethod=getProcessSuperviseCountMap&arguments=${JSON.stringify(
            sendParams
          )}`;
          const url = `${window._ctxPath}/ajax.do?method=ajaxAction&managerName=affairManager&rnd=6714`;

          if (this.isShowStatisticalToolBar && this.isShowTotal) {
            window.axios
              .post(url, args, {
                headers: {
                  'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
                }
              })
              .then((data, err) => {
                console.log(err, 'err');
                const result = data.data;
                this.statisticListArr = recieveData.pageHead.items.filter((item) => {
                  if (hideValueKeys.includes(item.key)) {
                    // 这几种类型不需要显示统计value
                    item.hideValue = true;
                  }
                  if (result.hasOwnProperty(item.key)) {
                    item.value = result[item.key];
                  }
                  return statisticListShowMap[item.key];
                });
              });
          }
          if (!this.currentChooseVal && this.statisticListArr.length) {
            this.currentChooseVal = this.statisticListArr[0].key;
            // this.needStatisticsVal = false;
            // this.initPageStatisticData();
            this.initToolbar();
            this.initTableData();
          } else {
            this.initToolbar();
            if (this.currentChooseVal == 'done') {
              this.getDoneTableData();
            }
            if (this.currentChooseVal != 'done' && this.currentChooseVal != 'workflowBug') {
              this.initTableData();
            }
          }

          this.initProcessShowType();
        });
      },
      initTableData() {
        this.$refs.avirtuallyTable && this.$refs.avirtuallyTable.cleanSelection();
        let extendParams = {};
        if (this.urlParamObj1.templeteIds) {
          extendParams.operationType = 'template';
          extendParams.operationTypeIds = this.urlParamObj1.templeteIds;
        } else if (this.globalParam.templateIds) {
          extendParams.operationType = 'template';
          extendParams.operationTypeIds = this.globalParam.templateIds;
        }
        let cachParams = {
          subject: this.searchValue,
          managerType: 'deptAdmin',
          operationType: 'template',
          dataType: this.currentChooseVal,
          flowstate: '0',
          currentNodesInfo: this.memberIdStr,
          ...extendParams,
          ...this.queryCondition,
          ...this.specialSearchConditionParams
        };
        this.cachParams = cachParams;
        const pageInfo = {
          page: this.pagination.page
        };
        if (this.pagination.pageSize) {
          pageInfo.size = this.pagination.pageSize;
        }
        const sendParams = [pageInfo, cachParams];
        const args = `managerMethod=getSuperviseListForOverDue&arguments=${formatRequestDataToJSON(
          sendParams
        )}`;
        const url = `${window._ctxPath}/ajax.do?method=ajaxAction&managerName=workflowManageManager&rnd=6714`;

        if (this.cancelToken && this.cancelToken.cancel) {
          this.cancelToken.cancel();
          this.cancelToken = null;
        }
        this.cancelToken = axios.CancelToken.source();

        window.axios
          .post(url, args, {
            cancelToken: this.cancelToken.token,
            headers: {
              'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
            }
          })
          .then((data, err) => {
            console.log(err, 'err');
            const result = data.data;
            if (result) {
              this.pagination.total = result.total;
              this.dataSource = result.data;
              if (this.statisRecieveData?.pageHead) {
                let curItem = this.statisRecieveData.pageHead.items.find((item) => {
                  return item.key === this.currentChooseVal;
                });
                // curItem && (curItem.value = result.total);
                this.updadeStatisticsBar(this.statisRecieveData);
              }
              if (this.specialSearchConditionParams?.clickedItemId) {
                this.specialSearchConditionList.forEach((item) => {
                  if (this.specialSearchConditionParams.operationTypeIds == item.templateId) {
                    item.values.forEach((val) => {
                      if (val.id == this.specialSearchConditionParams.clickedItemId) {
                        val.name = val.name.replace(/(>\S*<)/, `>${result.total}<`);
                      }
                    });
                  }
                });
              }
              this.loading = false;
            }
          });
      },
      dataTypeChange(key) {
        this.currentChooseVal = key;
        this.queryCondition = {};
        if (key != 'workflowBug') {
          this.initToolbar();
          this.initPageStatisticData();
          // this.initTableData();
        }
        // if (key == 'done') {
        //   this.getDoneTableData();
        // }
        // if (key != 'done' && key != 'workflowBug') {
        //   this.initTableData();
        // }
      },
      getDoneTableData(params) {
        this.loading = true;
        this.$refs.avirtuallyTable && this.$refs.avirtuallyTable.cleanSelection();
        let extendParams = {};
        if (this.urlParamObj1.templeteIds) {
          extendParams.operationType = 'template';
          extendParams.operationTypeIds = this.urlParamObj1.templeteIds || '';
        } else {
          extendParams.operationType = 'template';
          extendParams.operationTypeIds = this.globalParam.templateIds || '';
        }
        let cachParams = {
          subject: this.searchValue,
          managerType: 'deptAdmin',
          operationType: 'template',
          dataType: this.currentChooseVal,
          flowstate: '0',
          sourceType: '0',
          status: '1',
          ...params,
          ...extendParams,
          ...this.queryCondition
        };
        this.cachParams = cachParams;
        const pageInfo = {
          page: this.pagination.page
        };
        if (this.pagination.pageSize) {
          pageInfo.size = this.pagination.pageSize;
        }
        const sendParams = [pageInfo, cachParams];
        const args = `managerMethod=getAllSuperviseList4Col&arguments=${formatRequestDataToJSON(
          sendParams
        )}`;
        const url = `${window._ctxPath}/ajax.do?method=ajaxAction&managerName=superviseManager`;
        window.axios
          .post(url, args, {
            headers: {
              'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
            }
          })
          .then((data, err) => {
            console.log(err, 'err');
            const result = data.data;
            if (result) {
              this.pagination.total = result.total;
              this.dataSource = result.data;
              this.loading = false;
            }
          });
      },
      cancelSelected() {
        this.showCounter = false;
        // this.selectedRows = [];
        // this.selectedRowKeys = [];
        this.$refs.avirtuallyTable && this.$refs.avirtuallyTable.cleanSelection();
      },
      //按钮点击事件
      buttonClick(buttonKey) {
        let extendParams = {};
        if (this.urlParamObj1.templeteIds) {
          extendParams.operationType = 'template';
          extendParams.operationTypeIds = this.urlParamObj1.templeteIds || '';
        } else {
          extendParams.operationType = 'template';
          extendParams.operationTypeIds = this.globalParam.templateIds || '';
        }
        switch (buttonKey) {
          case 'allEditWorkFlow':
            this.batchEditAllFlowChart(
              this.dataSource,
              () => {
                this.initTableData();
                this.$emit('updadeStatisticsBar');
              },
              {
                managerType: this.managerType,
                dataType: this.currentChooseVal,
                searchParams: {
                  subject: this.searchValue,
                  managerType: 'deptAdmin',
                  // operationType: 'template',
                  dataType: this.currentChooseVal,
                  flowstate: '0',
                  ...extendParams,
                  ...this.queryCondition
                },
                urlParams: this.urlParamObj
              }
            );
            break;
          case 'batchEditWorkFlow_sub':
            this.batchEditFlowChart(
              this.selectedRows,
              () => {
                this.initTableData();
                this.$emit('updadeStatisticsBar');
              },
              {
                managerType: this.managerType,
                dataType: this.currentChooseVal
              }
            );
            break;
          case 'urgeDeal':
            if (this.selectedRowKeys.length > 1) {
              Fiber.message.warning($.i18n('supervise.onlyOne.data.operation'));
            } else if (this.selectedRowKeys.length < 1) {
              Fiber.message.warning($.i18n('supervise.please.select.operation.data'));
            } else {
              this.urgeDealHandler(this.selectedRows[0], this.initTableData);
            }
            break;
          case 'export':
            this.exportExcel(this.cachParams, this.pagination.total, {
              managerType: 'deptAdmin',
              dataType: this.currentChooseVal
            });
            break;
          case 'print':
            // this.popprint(this.$refs.tableContent.innerHTML);
            this.showPagination = false;
            this.$nextTick(() => {
              this.popprint(this.$el.outerHTML);
              this.showPagination = true;
            });
            break;
          case 'editWorkFlowLog':
            this.editWorkFlowLog();
            break;
          case 'deleteSupervise':
            this.deleteSupervise(this.selectedRows, () => {
              this.getDoneTableData();
            });
            break;
          case 'editWorkFlow':
            if (this.selectedRowKeys.length > 1) {
              Fiber.message.warning($.i18n('supervise.onlyOne.data.operation'));
            } else if (this.selectedRowKeys.length < 1) {
              Fiber.message.warning($.i18n('supervise.please.select.operation.data'));
            } else {
              this.editFlowChart(
                this.selectedRows[0],
                {
                  saveDBOK: {
                    show: true,
                    callback: () => {}
                  },
                  repeal: {
                    show: true,
                    callback: () => {}
                  },
                  stop: {
                    show: true,
                    callback: () => {}
                  },
                  close: {
                    show: true,
                    callback: () => {}
                  }
                },
                { managerType: 'deptAdmin', dataType: this.currentChooseVal }
              );
            }
            break;
          case 'processEnd':
            this.stopWorkflow(this.selectedRows);
            break;
          case 'processRevoke':
            this.repealWorkflow(this.selectedRows);
            break;
          case 'dealProblem':
            this.dealflowChart(this.selectedRows[0], () => {
              this.initTableData();
              this.$emit('updadeStatisticsBar');
            });
            break;
        }
      },
      checkSizeForToolBar() {
        var selectRows = this.selectedRowKeys;
        if (selectRows.length === 0) {
          Fiber.message.warning($.i18n('supervise.please.select.operation.data')); //请选择要操作的数据！
          return false;
        } else if (selectRows.length > 1) {
          Fiber.message.warning($.i18n('supervise.onlyOne.data.operation')); //只能选择一条数据进行操作！
          return false;
        }
        return true;
      },
      stopWorkflow(_data, dialog, chooseData) {
        if (!this.checkSizeForToolBar()) {
          return;
        }
        var data = chooseData[0];

        if (!data.affairId) {
          Fiber.message.warning($.i18n('workflow.supervise.bugreport.canot.operation.js'));
          return;
        }
      },
      onSelectChange(selectedRowKeys, selectedRows) {
        this.selectedRowKeys = selectedRowKeys;
        this.selectedRows = selectedRows;
      },
      // onSelectRecord(record, selected, selectedRows) {
      //   this.selectedRows = selectedRows;
      // },
      handleTableChange(page, pageSize) {
        this.pagination.page = page;
        this.pagination.pageSize = pageSize;
        this.initTableData();
      },
      paginationShowSizeChange(current, size) {
        this.pagination.page = 1;
        this.pagination.pageSize = size;
        this.initTableData();
      },
      handleSearchConditionChange(condition) {
        this.specialSearchSelectedValue = '';
        this.specialSearchConditionParams = null;
        this.pagination.page = 1;
        //重要程度，状态
        const enumKeys = ['importLevel', 'importantLevelList', 'subState'];
        Object.keys(condition).forEach((key) => {
          if (enumKeys.includes(key)) {
            condition[key] = condition[key].join(',');
          }
        });
        //发起时间
        if (condition.createDate) {
          condition.beginDate = condition.createDate.startDate;
          condition.endDate = condition.createDate.endDate;
        }
        //流程期限
        if (condition.deadlineDatetime) {
          condition.deadlineBeginDate = condition.deadlineDatetime.startDate;
          condition.deadlineEndDate = condition.deadlineDatetime.endDate;
        }
        //当前待办人
        if (condition.currentNodesInfoStr) {
          condition.currentNodesInfo = condition.currentNodesInfoStr.value;
          delete condition.currentNodesInfoStr;
        }
        //发起对象
        if (condition.startMemberName) {
          // condition.startMemberName = condition.startMemberName.value;
          condition.senders = condition.startMemberName.value;
          delete condition.startMemberName;
        }
        //模版流程
        if (condition.processTemplateName) {
          condition.operationTypeIds = condition.processTemplateName.value;
        }
        //事项所属人
        // if (condition.belongMember) {
        //   condition.belongMember = condition.belongMember;
        // }
        this.queryCondition = condition;
        this.initTableData();
      },
      handleSearch(val) {
        this.specialSearchSelectedValue = '';
        this.specialSearchConditionParams = null;
        this.queryCondition.subject = val;
        this.searchValue = val;
        this.pagination.page = 1;
        this.initTableData();
      },
      expandChange(isExpanded) {
        this.$nextTick(() => {
          this.$refs.avirtuallyTable && this.$refs.avirtuallyTable.resizeTable();
        });
        console.log(isExpanded);
      }
    }
  };
</script>
<style>
  @import url('../../assets/css/common.css');
</style>
<style lang="scss">
  .supervise-list-outer-wrapper {
    height: 100%;
  }
  .currentNodesInfo {
    color: #2490f8;
    color: var(--theme-brand5, #2490f8);
  }
  .search-condition-container {
    margin-left: 16px;
  }
  .supervise-list-container {
    text-align: center;
    color: #2c3e50;
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
    // background-color: #ffffff;
    background-color: #ffffff;
    .pending-list-main {
      position: absolute;
      left: 0;
      right: 0;
      bottom: 0;
      top: 85px;
      display: flex;
      flex-direction: column;
      background-color: #ffffff;
      .pending-list-header {
        display: flex;
        padding: 12px 16px 12px 16px;
        height: 54px;
        box-sizing: border-box;
      }

      .search-part {
        display: flex;
        justify-content: flex-end;
        overflow: hidden;
        margin-left: 100px;
      }

      .pending-list-content {
        position: relative;
        flex: 1;
        padding: 0 10px 0 16px;
        overflow: hidden;

        > div {
          position: absolute;
          left: 0;
          top: 0;
          right: 0;
          bottom: 0;
        }
      }
      .tag-show {
        border-radius: 2px;
        border: none;
      }
    }
  }
  .print-supervise {
    .pending-list-main {
      position: relative;
      top: 0px !important;
    }
    .statistic-tabs-header {
      display: none;
    }
    .supervise-list-container .pending-list-main .pending-list-header {
      display: none;
    }
    .common-counter {
      display: none;
    }
    .common-toolbar {
      display: none;
    }
    .search-part {
      display: none;
    }
    .search-input {
      display: none;
    }
    .search-condition {
      display: none;
    }
    .search-condition-container {
      display: none;
    }
    .ant-table-body {
      height: auto !important;
      max-height: none !important;
    }
    .scrollbar {
      display: none;
    }
    .supervise-list-container .pending-list-main .pending-list-content > div {
      position: relative;
    }
  }

  #context.content.set_ul_ls {
    // 打印的时候需要用到，解决多出一页空白的问题
    border: 1px solid white;
  }
</style>
